<template>
  <div id="trajectory" v-loading="!ready">
    <div ref="track-container"  style="width:100%; height:400px; background-color: #fff;"></div>
  </div>
</template>

<script>
import trajectory from "../../api/js/WorkOpt/OneWork/trajectory";

export default {
  name: "trajectory",
  data() {
    return {
      data: [],
      ready: false
    };
  },

  beforeCreate() {
  },

  created() {
  },
  mounted() {
    this.$Bus.$on("track", () => {
      this.data = this.$store.getters.getTrack;
      this.drawing();
    });
  },

  methods: {
    async drawing() {
      // waiting dom refresh
      await this.$nextTick()
      let nodeDataArray = []
      this.data.WF_Node.forEach(item => {
        nodeDataArray.push({
          key: item.ID,
          parent: item.ID - 1,
          name1: item.Name,
          img: ''
        });
      });
      const container = this.$refs['track-container']
      trajectory(this, nodeDataArray, container);
      this.ready = true
    }
  },

  //监听
  computed: {},

  components: {},

  //监听后执行动作
  watch: {}
};
</script>

<style lang="less" scoped>
</style>
